<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <!--<div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
        </a-row>
      </a-form>
    </div>-->
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="getList" type="primary">刷新</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel">
            <a-icon type="delete"/>
            删除
          </a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作
          <a-icon type="down"/>
        </a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
        style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table ref="table" size="middle" :scroll="{x:true}" bordered rowKey="id" :columns="columns"
               :dataSource="dataSource" :pagination="ipagination"
               :loading="loading" :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
               class="j-table-force-nowrap"
               @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="nicknameSlot" slot-scope="text,record">
          <div>{{ record.umsMember.nickname }}</div>
        </template>
        <template slot="phoneSlot" slot-scope="text,record">
          <div>{{ record.umsMember.phone }}</div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="55px" alt=""
               style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="statusSlot" slot-scope="text">
          <a-tag color="orange" v-if="text==0">
            待处理
          </a-tag>
          <a-tag color="green" v-else>
            已处理
          </a-tag>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleClick(record.id)" v-if="record.status==0">处理</a>
          <!-- <a @click="handleClick(record)" v-if="record.status==1">撤销处理</a> -->
          <a-divider v-if="record.status==0" type="vertical"/>
          <a-dropdown>
            <a @click="handleDetail(record)" class="ant-dropdown-link">详情</a>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <a-modal title="反馈" :visible="downVisible" :confirm-loading="down_confirmLoading" @ok="handleClickOk()"
             @cancel="downVisible= false">
      <p>
        <a-textarea placeholder="请输入反馈内容" :rows="4" v-model="auditRemark"/>
      </p>
    </a-modal>
    <cms-feedback-modal ref="modalForm" @ok="modalFormOk"></cms-feedback-modal>
  </a-card>
</template>

<script>


import '@/assets/less/TableExpand.less'
import {mixinDevice} from '@/utils/mixin'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import CmsFeedbackModal from './modules/CmsFeedbackModal'
import {putAction} from "../../../api/manage"
import {getAction} from "../../../api/manage"

export default {
  name: 'CmsFeedbackList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    CmsFeedbackModal
  },
  data() {
    return {
      downVisible: false,
      down_confirmLoading: false,
      auditRemark: '',
      select_id: null,
      status_show: true, //处理状态
      description: 'cms_feedback管理页面',
      // 表头
      columns: [
        {
          title: '序号',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '昵称',
          align: "center",
          dataIndex: 'uid',
          scopedSlots: {customRender: 'nicknameSlot'}
        },
        {
          title: '手机号',
          align: "center",
          dataIndex: 'uid1',
          scopedSlots: {customRender: 'phoneSlot'}
        },
        {
          title: '建议内容',
          align: "center",
          dataIndex: 'remark',
          scopedSlots: {customRender: 'htmlSlot'}
        },
        {
          title: '是否被处理',
          align: "center",
          dataIndex: 'status',
          scopedSlots: {customRender: 'statusSlot'}
        },
        {
          title: '反馈时间',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          width: 147,
          scopedSlots: {customRender: 'action'}
        }
      ],
      url: {
        list: "/common/cmsFeedback/list",
        delete: "/common/cmsFeedback/delete",
        deleteBatch: "/common/cmsFeedback/deleteBatch",
        exportXlsUrl: "/common/cmsFeedback/exportXls",
        importExcelUrl: "common/cmsFeedback/importExcel",
        edit: "/common/cmsFeedback/edit"

      },
      dictOptions: {},
    }
  },
  created() {

  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
  },
  methods: {
    handleClick(id) {
      this.select_id = id
      this.downVisible = true
      this.down_confirmLoading = false
      this.auditRemark = ''
    },
    //处理按钮点击事件
    handleClickOk() {
      this.down_confirmLoading = true
      putAction(this.url.edit, {id: this.select_id, status: 1, auditRemark: this.auditRemark}).then((res) => {
        if (res.success) {
          this.getList()
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
        this.downVisible = false
        this.down_confirmLoading = false
      })

    },

    getList() { //获取所有list
      getAction(this.url.list).then((res) => {
        if (res.success) {
          this.dataSource = res.result.records
          this.ipagination.total = res.result.total
        }
        if (res.code === 510) {
          this.$message.warning(res.message)
        }
        this.loading = false
      })
    },
  }

}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
